CREATE TABLE [dbo].[Stock]
(
[StockId] [bigint] NOT NULL IDENTITY(1, 1),
[DrugId] [nvarchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Quantity] [int] NOT NULL,
[UnitPrice] [decimal] (18, 0) NOT NULL,
[ExpDate] [datetime] NULL,
[BatchLot] [nvarchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Remark] [nvarchar] (250) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Stock] ADD CONSTRAINT [PK_Stock] PRIMARY KEY CLUSTERED  ([StockId]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_Stock] ON [dbo].[Stock] ([DrugId]) ON [PRIMARY]
GO
CREATE UNIQUE NONCLUSTERED INDEX [IX_Stock_2] ON [dbo].[Stock] ([DrugId], [ExpDate], [BatchLot]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Stock] ADD CONSTRAINT [FK_Stock_DrugDispo] FOREIGN KEY ([DrugId]) REFERENCES [dbo].[DrugDispo] ([DrugId])
GO
